# -*- encoding: utf-8 -*-
'''
@File    :   normalization.py
@Time    :   2021/12/3 11:01
@Author  :   ZhangChaoYang
@Desc    :   
'''

import numpy as np


def layer_norm(data):
    '''
    一个样本内部进行正态归一化
    '''
    x = data.reshape((data.shape[0], -1))
    mean = np.mean(x, axis=1).reshape((-1, 1))
    std_var = np.std(x, axis=1).reshape((-1, 1))
    norm = (x - mean) / std_var
    return norm.reshape(data.shape)